import request from '@/utils/request'
import storage from '@/utils/storage'

const dataInfo = JSON.parse(storage.get('userInfo'))

// 广告列表
export function fetchAdvertList(params) {
    return request({
        url: '/operation/opAdvert/queryList',
        method: 'get',
        params: {
        'directoryId': params.directoryId,
        'name': params.name     ,
        'startDate': params.startDate,
        'endDate': params.endDate,
        'status': params.status,
        'pageIndex': params.pageIndex,
        'pageSize': params.pageSize
        },
        port: { ENV_PORT: 8004 },
        ajaxType2: 'reqGet'
    })
}

// 广告详情
export function advertDetail(id) {
    return request({
      url: '/operation/opAdvert/detail',
      method: 'get',
      params: {'id': id},
      port: { ENV_PORT: 8004 },
      ajaxType2: 'reqGet'
    })
  }

//添加广告
export function advertAdd(data) {
  return request({
    url: '/operation/opAdvert/add',
    method: 'post',
    data,
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqPost'
  })
}

// 删除广告
export function advertDelete(id) {
  return request({
    url: '/operation/opAdvert/delete',
    method: 'delete',
    params:{id},
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqDelete'
  })
}

//审核广告
export function advertApprove(data) {
  return request({
    url: '/operation/opAdvert/approve',
    method: 'put',
    data,
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqPut'

  })
}

//修改广告
export function advertUpdate(data) {
  return request({
    url: '/operation/opAdvert/update',
    method: 'put',
    data,
    port: { ENV_PORT: 8004 },
    ajaxType2: 'reqPut'

  })
}
